import '../../scss/bag.scss'
import React from 'react'
import { userApi } from '../../api/user'
import { commonApi } from '../../api/common'

export default React.createClass({
    getInitialState() {
        return { bag: null }
    },
    componentDidMount() {
        let self = this
        userApi.getBagInfo(function (err, data) {
            self.setState({ bag: data })
        })
    },
    render() {
        var bag = {},
            itemsNode,
            node
        if (this.state.bag) {
            bag = this.state.bag
            itemsNode = bag.items.map(function (item) {
                return <div className="item"></div>
            })
        }
        return <div id="bag">
            <div className="head">
                <div className="title">背包</div>
                <div className="title">背包大小{bag.size}空格子{bag.emptySize}</div>
            </div>
            <div className="flex jc-around wrap">{itemsNode}</div>
        </div>
    }
})
